import http from "@/utils/request";
let userid = localStorage.getItem("userid");
// 加入购物车请求
function cartAddReq(userid,proid,num){
    return http({
        method:"post",
        url:"/api/cart/add",
        data:{userid,proid,num}
    })
}
// 购物车列表请求
function cartListReq(){
    return http({
        method:"post",
        url:"/api/cart/list",
        data:{userid}
    })
}
// 删除购物车单条数据
function cartDeleteReq(cartid){
    return http({
        method:"post",
        url:"/api/cart/remove",
        data:{cartid}
    })
}
// 更新购物车数量
function cartUpdateNumReq(cartid,num){
    return http({
        method:"post",
        url:"/api/cart/updatenum",
        data:{cartid,num}
    })
}
// 更新当前购物车数据的选中状态
function cartSelectOneReq(cartid,flag){
    return http({
        method:"post",
        url:"/api/cart/selectone",
        data:{cartid,flag}
    })
}
// 更新所有购物车数据的选中状态
function cartSelectAllReq(type){
    return http({
        method:"post",
        url:"/api/cart/selectall",
        data:{userid,type}
    })
}
export{
    cartAddReq,
    cartListReq,
    cartDeleteReq,
    cartUpdateNumReq,
    cartSelectOneReq,
    cartSelectAllReq,
};